package com.wwg.spring.bean.init;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @类描述: 构造函数 属性注入 InitializingBean的执行顺序
 * @Author wwg
 * @date: 2021/7/14 18:29
 * @Version: 1.0
 **/
//@Component
public class MyInitializingBean implements InitializingBean {

    public MyInitializingBean() {
        System.out.println("实例化 》》》");

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Value("zhangsan")
    String name;

    @Value("99")
    private int age;

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet方法开始》》 看看此时的bean");

        System.out.println(this);

        if (age>80) {

        }

        System.out.println("afterPropertiesSet方法结束》》 ");

    }

    private void init() {
        System.out.println("init方法》》");
    }
}
